package com.vast.controller;


import com.vast.entity.AnswerEntity;
import com.vast.entity.ProblemEntity;
import com.vast.service.AnswerService;
import common.utils.Result;
import common.utils.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/answer")
@CrossOrigin
public class AnswerController {

    @Autowired
    AnswerService answerService;
    @Autowired
    MongoTemplate mongoTemplate;

    /**
     * 查询问题答案
     * @param
     * @return
     */
    @PostMapping("/getAnswerList")
    public Result getAnswerListByProId(@RequestBody ProblemEntity problemEntity){
      Result list=  answerService.getAnswerListByProId(problemEntity);
        return new Result(StatusCode.OK,"答案数据查询成功",true,list);
    }
    /**
     * 添加答案
     * @param
     * @return
     */
    @RequestMapping("/saveAnswer")
    public Result saveAnswer(@RequestBody AnswerEntity answerEntity){
        mongoTemplate.save(answerEntity);
        return new Result(StatusCode.OK,"答案数据添加成功",true);
    }
}
